#!/bin/bash

REBUILD=1

#VS=12
VS=10

JNADIR="c:/opt/jna"

PREFIX="${JNADIR}"

CPP="${JNADIR}/deps/shared"

FLAGS=""

FLAGS="-DCMAKE_INSTALL_PREFIX=${PREFIX} ${FLAGS}"
FLAGS="-DCMAKE_PREFIX_PATH=${CPP} ${FLAGS}"

FLAGS="-DHDF5_DIR=${CPP}/cmake/hdf5 ${FLAGS}"

FLAGS="-DNETCDF_ENABLE_CONVERSION_WARNINGS=OFF ${FLAGS}"
FLAGS="-DNETCDF_BUILD_UTILITIES=OFF ${FLAGS}"
FLAGS="-DNETCDF_ENABLE_EXAMPLES=OFF ${FLAGS}"
FLAGS="-DENABLE_V2_API=OFF ${FLAGS}"
FLAGS="-DENABLE_JNA=ON ${FLAGS}"

if test "x${REBUILD}" = x1 ; then
  rm -fr ./build
  mkdir build
fi
pushd build
if test "x${REBUILD}" = x1 ; then
cmake -G"Visual Studio ${VS}" ${FLAGS} ..
fi
cmake --build . --config Release
cmake --build . --target INSTALL
popd

pushd ${PREFIX}
sh ../setup
popd

exit
